/**
 * UI时间组件,提供时间选择，只能选择，不能手动填写
 * @author zhaojh
 */
function DatePickerObj(o){
	this.editor = o;
	this.baseObj = null;
}

DatePickerObj.prototype.toString = function(){
	return "DatePickerObj";
}

DatePickerObj.prototype.onReady = function(){
//	this.getBaseObj().onReady();
    var $editor = jQuery(this.editor);
    
    //指定时间控件的样式
    $editor.addClass("Wdate");
    
    //设置只读属性
    $editor.attr("readonly","readonly");

    //时间控件参数对象
    var options = new Object();
    //皮肤,默认皮肤为 ext
    var skin = $editor.attr("theme");
    if(skin && jQuery.trim(skin) != ""){
    	options.skin = skin;
    }else {
		if(easytogo_theme && easytogo_theme == 'default'){
			options.skin = 'default';
		}
		if(easytogo_theme && easytogo_theme == 'blue'){
			options.skin = 'blue';
		}
		if(easytogo_theme && easytogo_theme == 'ext'){
			options.skin = 'ext';
		}
		if(easytogo_theme && easytogo_theme == 'whyGreen'){
			options.skin = 'whyGreen';
		}
	}
	//语言
	if(easytogo_locale){
		options.lang = easytogo_locale.toLowerCase();
	}
    //日期格式,默认格式为 yyyy-MM-dd
    var dateformat = $editor.attr("dateformat");
    if(dateformat && jQuery.trim(dateformat) != ""){
    	options.dateFmt = dateformat
    }else{
    	options.dateFmt = "yyyy-MM-dd";
    }
    //比某个时间控件的日期大或一样(注意2个日期控件的格式一样)
    var afterFor = $editor.attr("afterFor");
    if(afterFor && jQuery.trim(afterFor) != ""){
    	options.minDate="#F{$dp.$D(\'"+afterFor+"\')}";
    }
	//比某个时间控件的日期小或一样(注意2个日期控件的格式一样)
	var beforeFor = $editor.attr("beforeFor");
    if(beforeFor && jQuery.trim(beforeFor) != ""){
    	options.maxDate="#F{$dp.$D(\'"+beforeFor+"\')}";
    }
	
    //绑定input text 的onclick事件，在出发此事件时，弹出时间选择框
    //设置是否可用
    var disabled = $editor.attr("isdisabled");
   	if(jQuery.trim(disabled) == false){
	    $editor.bind("click",options,function(event){
	    	WdatePicker(options);
	    });
    }
}